﻿@using zichan.Entity
@using zichan.Common;
@model IPagedList<Asset>
@{
    ViewBag.Title = "资产管理列表";
}

@section Pagetitle{
    @AdminCommon.PageTitle("资产管理列表", "出库/入库/报废")
}
<style>
    #pagebar li {
        display: inline-block;
    }
</style>
<div class="portlet">
    <div class="portlet-title">
        <div class="caption ">
            <i class="fa fa-table"></i>资产管理列表
        </div>
    </div>
    <div class="portlet-body">
        <div class="table-container">
            <div class="dataTables_wrapper dataTables_extended_wrapper no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="table-group-actions pull-left">
                            @using (Html.BeginForm("index", "RepertoryManage", FormMethod.Get, new { @class = "form-inline" }))
                            {
                                <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                <div class="help-block">
                                    <input type="hidden" name="serverPurposeId" value="@ViewBag.serverPurposeId" />
                                    <div class="form-group">
                                        <input type="text" placeholder="请输入资产编号" name="code" value="@ViewBag.code" class="form-control input-small input-sm" />
                                    </div>
                                    <div class="form-group">
                                        <input type="text" placeholder="请输入使用者" name="userName" value="@ViewBag.userName" class="form-control input-small input-sm" />
                                    </div>
                                    <div class="form-group">
                                        <input type="text" placeholder="请输入资产名称" name="name" value="@ViewBag.name" class="form-control input-small input-sm" />
                                    </div>
                                    <div class="form-group">
                                        <input type="text" placeholder="使用记录备注关键字" name="remarkKeyword" value="@ViewBag.remarkKeyword" class="form-control input-small input-sm" />
                                    </div>
                                    <div class="form-group">
                                        <input type="text" placeholder="请输入管理员名称" name="adminName" value="@ViewBag.adminName" class="form-control input-small input-sm" />
                                    </div>
                                    <div class="form-group">
                                        @Html.DropDownList("assetClassId", (SelectList)ViewBag.assetClassIds, "全部资产分类", new { @class = "form-control input-small input-sm" })
                                    </div>
                                </div>
                                <div class="help-block">
                                    <div class="form-group">
                                        @Html.DropDownList("companyId", (SelectList)ViewBag.companyIds, "全部公司", new { @class = "form-control input-small input-sm" })
                                    </div>
                                    <div class="form-group">
                                        @Html.DropDownList("statu", (SelectList)ViewBag.status, "全部状态", new { @class = "form-control input-small input-sm" })
                                    </div>
                                    <div class="form-group">
                                        <div class="input-group">
                                            <input type="text" placeholder="采购时间" name="sdt" id="sdt" value="@ViewBag.sdt" class="form-control input-small input-sm dateSdt" />
                                            <span class="input-group-addon dateSdt">
                                                <i class="fa fa-calendar bigger-110 "></i>
                                            </span>
                                        </div>
                                        至
                                        <div class="input-group">
                                            <input type="text" placeholder="采购时间" name="edt" id="edt" value="@ViewBag.edt" class="form-control input-small input-sm dateEdt" />
                                            <span class="input-group-addon dateEdt">
                                                <i class="fa fa-calendar bigger-110"></i>
                                            </span>
                                        </div>
                                    </div>
                                    <button class="btn btn-sm yellow table-group-action-submit"><i class="fa fa-check"></i> 搜索</button>
                                </div>
                            }
                        </div>
                    </div>
                </div>
                <div class="form-group"><h5>列表总数:<span style="color:red;">@Model.TotalItemCount</span></h5></div>
                <div class="table-scrollable">
                    <table class="table  table-hover">
                        <thead>
                            <tr class="heading">
                                <th>资产编号</th>
                                <th>资产分类</th>
                                <th>资产名称</th>
                                <th>所属公司</th>
                                <th>使用者</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (Asset r in Model)
                            {
                                <tr>
                                    <td>@r.Code</td>
                                    <td>@r.AssetClassName</td>
                                    <td>@r.Name</td>
                                    <td>@r.CompanyName</td>
                                    <td>@r.UserName</td>
                                    <td>
                                        @{
                                            if (r.Status == (int)AsseteStatu.Repertory)
                                            {
                                                @*<span class='label label-sm label-warning'>使用中</span>*@
                                                @("库存")
                                            }
                                            if (r.Status == (int)AsseteStatu.InUse)
                                            {
                                                @*<span class='label label-sm label-warning'>使用中</span>*@
                                                @("使用中")
                                            }
                                            if (r.Status == (int)AsseteStatu.Scrap)
                                            {
                                                @*<span class='label label-sm label-warning'>使用中</span>*@
                                                @("报废")
                                            }
                                        }
                                    </td>
                                    <td>
                                        @if (PowerHelp.Check("RepertoryManage", "Details"))
                                        {
                                            <a href="@Url.Action("Details", "RepertoryManage", new {id=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-search"></i> 详情
                                            </a>
                                        }
                                        @if (PowerHelp.Check("RepertoryManage", "OutWareHouse") && r.Status == 1)
                                        {
                                            <a href="@Url.Action("OutWareHouse","RepertoryManage",  new {id=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-edit"></i> 出库
                                            </a>
                                        }

                                        @if (PowerHelp.Check("RepertoryManage", "PutWareHouse") && r.Status == 2)
                                        {
                                            <a href="@Url.Action("PutWareHouse","RepertoryManage",  new {id=r.Id })" class="btn default btn-xs purple">
                                                <i class="fa fa-edit"></i> 入库
                                            </a>
                                        }

                                    </td>
                                </tr>
                                            }
                        </tbody>
                    </table>
                </div>
                @if (PowerHelp.Check("Excel", "AssetExc"))
                {
                    <div class="row">
                        <div class="col-md-12">
                            <a href="@Url.Action("AssetExc", "Excel", new {code=ViewBag.code, userName=ViewBag.userName, name=ViewBag.name, remarkKeyword=ViewBag.remarkKeyword, adminName=ViewBag.adminName, assetClassId=ViewBag.assetClassId,serverPurposeId=ViewBag.serverPurposeId, companyId=ViewBag.companyId, statu=ViewBag.statu, sdt=ViewBag.sdt, edt=ViewBag.edt})" class="btn default green">
                                <i class="fa fa-table"></i>
                                <span class="hidden-480">Excel导出报表</span>
                            </a>
                        </div>
                    </div>
                }

                <div class="row">
                    <div class="col-sm-12 dataTables_paginate">
                        <div class="pull-right">
                            <ul id="pagebar" style="display:inline-block;margin-right:10px;">
                                <li>
                                    每页<select name="pageSize" id="pageSize" class="select2" style="width:50px;font-size:18px;">
                                        <option value="@ViewBag.pageSize">@ViewBag.pageSize</option>
                                        @foreach (var s in ViewBag.pageSizes)
                                        {
                                            <option value="@s.Value">@s.Text</option>
                                        }
                                    </select>个
                                </li>
                                <li>第@(Model.PageNumber)/共@(Model.PageCount)页</li>
                                @using (Html.BeginForm("index", "RepertoryManage", FormMethod.Get, new { @style = "display: inline-block;" }))
                                {
                                    <li style="display:none;">
                                        <input type="hidden" name="pageSize" value="@ViewBag.pageSize" />
                                        <input type="hidden" name="code" value="@ViewBag.code" />
                                        <input type="hidden" name="userName" value="@ViewBag.userName" />
                                        <input type="hidden" name="name" value="@ViewBag.name" />
                                        <input type="hidden" name="remarkKeyword" value="@ViewBag.remarkKeyword" />
                                        <input type="hidden" name="adminName" value="@ViewBag.adminName" />
                                        <input type="hidden" name="assetClassId" value="@ViewBag.assetClassId" />
                                        <input type="hidden" name="serverPurposeId" value="@ViewBag.serverPurposeId" />
                                        <input type="hidden" name="companyId" value="@ViewBag.companyId" />
                                        <input type="hidden" name="statu" value="@ViewBag.statu" />
                                        <input type="hidden" name="sdt" value="@ViewBag.sdt" />
                                        <input type="hidden" name="edt" value="@ViewBag.edt" />
                                        @Html.TextBox("pageCount", Model.PageCount)
                                    </li>
                                    <li>跳转至<input name="selectedPage" style="width:40px;font-size:18px;" value="@ViewBag.selectedPage" />页</li>
                                    <li><button type="submit">GO</button></li>}
                            </ul>
                            @if (Model.PageCount > 1)
                            {
                                <ul id="pagebar" class="pagination" style="margin:0px;float:right;">
                                    <li><a href="@Url.Action("Index", "RepertoryManage", new { code = ViewBag.code, name = ViewBag.name, statu = ViewBag.statu, remarkKeyword = ViewBag.remarkKeyword, userName = ViewBag.userName, adminName = ViewBag.adminName, assetClassId = ViewBag.assetClassId,serverPurposeId=ViewBag.serverPurposeId, companyId = ViewBag.companyId, sdt = ViewBag.sdt, edt = ViewBag.edt, pageSize = ViewBag.pageSize,page = 1 })">首页</a></li>
                                    <li>@Html.ActionLink("上一页", "Index", "RepertoryManage", new { code = ViewBag.code, name = ViewBag.name, statu = ViewBag.statu, remarkKeyword = ViewBag.remarkKeyword, userName = ViewBag.userName, adminName = ViewBag.adminName, assetClassId = ViewBag.assetClassId, serverPurposeId = ViewBag.serverPurposeId, companyId = ViewBag.companyId, sdt = ViewBag.sdt, edt = ViewBag.edt, pageSize = ViewBag.pageSize, page = Model.PageNumber - 1 }, null)</li>
                                    <li>@Html.ActionLink("下一页", "Index", "RepertoryManage", new { code = ViewBag.code, name = ViewBag.name, statu = ViewBag.statu, remarkKeyword = ViewBag.remarkKeyword, userName = ViewBag.userName, adminName = ViewBag.adminName, assetClassId = ViewBag.assetClassId, serverPurposeId = ViewBag.serverPurposeId, companyId = ViewBag.companyId, sdt = ViewBag.sdt, edt = ViewBag.edt, pageSize = ViewBag.pageSize, page = (Model.PageNumber + 1 < Model.PageCount ? Model.PageNumber + 1 : Model.PageCount) }, null)</li>
                                    <li>@Html.ActionLink("末页", "Index", "RepertoryManage", new { code = ViewBag.code, name = ViewBag.name, statu = ViewBag.statu, remarkKeyword = ViewBag.remarkKeyword, userName = ViewBag.userName, adminName = ViewBag.adminName, assetClassId = ViewBag.assetClassId, serverPurposeId = ViewBag.serverPurposeId, companyId = ViewBag.companyId, sdt = ViewBag.sdt, edt = ViewBag.edt, pageSize = ViewBag.pageSize, page = Model.PageCount }, null)</li>
                                </ul>}
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

@section footer{
    <script src="/assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var formatDateTime = function (date) {
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            //m = m < 10 ? ('0' + m) : m;
            var d = date.getDate();
            //d = d < 10 ? ('0' + d) : d;
            //var h = date.getHours();
            //var minute = date.getMinutes();
            //minute = minute < 10 ? ('0' + minute) : minute;
            //return y + '/' + m + '/' + d + ' ' + h + ':' + minute;
            return y + '/' + m + '/' + d;
        };
        $('.dateSdt').datetimepicker({
            //language: 'zh-CN',
            weekStart: 1,
            todayBtn: 0,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            minView: 'month',　　　　//日期时间选择器所能够提供的最精确的时间选择视图。
            format: 'yyyy/m/d'
        }).on('changeDate', function (ev) {
            $("#sdt").val(formatDateTime(new Date(ev.date.valueOf() - 28800000)));
        });
        $('.dateEdt').datetimepicker({
            //language: 'zh-CN',
            weekStart: 1,
            todayBtn: 0,
            autoclose: 1,
            todayHighlight: 1,
            startView: 2,
            forceParse: 0,
            minView: 'month',　　　　//日期时间选择器所能够提供的最精确的时间选择视图。
            format: 'yyyy/m/d'
        }).on('changeDate', function (ev) {
            $("#edt").val(formatDateTime(new Date(ev.date.valueOf() - 28800000)));
        });
        $(function () {
            $('#pageSize').on("change", function () {
                var name = $("input[name='name']").val();
                var statu = $("input[name='statu']").val();
                var userName = $("input[name='userName']").val();
                var code = $("input[name='code']").val();
                var remarkKeyword = $("input[name='remarkKeyword']").val();
                var adminName = $("input[name='adminName']").val();
                var assetClassId = $("input[name='assetClassId']").val();
                var companyId = $("input[name='companyId']").val();
                var sdt = $("input[name='sdt']").val();
                var edt = $("input[name='edt']").val();
                var size = $(this).val();
                location.href = "/RepertoryManage/Index?code=" + code + "&userName=" + userName + "&name=" + name + "&remarkKeyword=" + remarkKeyword + "&adminName=" + adminName + "&assetClassId=" + assetClassId + "&companyId=" + companyId + "&statu=" + statu + "&sdt=" + sdt + "&edt=" + edt + "&pageSize=" + size;
            });

        });
    </script>
}
